package com.eastedu.repository.basic.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.eastedu.repository.basic.po.BasicResourcePO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * The interface Basic resource mapper.
 *
 * @author ZHISHUAI.ZHANG
 * @since 2019 /2/22
 */
@Mapper
public interface BasicResourceMapper extends BaseMapper<BasicResourcePO> {

    /**
     * Update knowledge json.
     *
     * @param basicResourceId the basic resource id
     * @param knowledgeJson   the knowledge json
     */
    @Update("UPDATE t_basic_resource SET knowledges_json = #{knowledgeJson}, update_time = update_time + 1 WHERE id = #{basicResourceId}")
    void updateKnowledgeJson(@Param("basicResourceId") String basicResourceId, @Param("knowledgeJson") String knowledgeJson);

    /**
     * Update files json.
     *
     * @param basicResourceId the basic resource id
     * @param filesJson       the files json
     */
    @Update("UPDATE t_basic_resource SET files_json = #{filesJson}, update_time = update_time + 1 WHERE id = #{basicResourceId}")
    void updateFilesJson(@Param("basicResourceId") String basicResourceId, @Param("filesJson") String filesJson);

    /**
     * Update source json and provider by resource id.
     *
     * @param po the po
     * @param id the id
     */
    @Update("UPDATE t_basic_resource SET sources_json = #{po.sourcesJson}, create_userid = #{po.createUserid}, update_time = update_time + 1 WHERE id = #{id}")
    void updateSourceJsonAndProviderByResourceId(@Param("po") BasicResourcePO po, @Param("id") String id);

    /**
     * Update source json by resource id.
     *
     * @param po the po
     * @param id the id
     */
    @Update("UPDATE t_basic_resource SET sources_json = #{po.sourcesJson}, update_time = update_time + 1 WHERE id = #{id}")
    void updateSourceJsonByResourceId(@Param("po") BasicResourcePO po, @Param("id") String id);
}
